package com.thinkgsp.jxc.model;

import java.math.BigDecimal;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.thinkgsp.report.ReportUtils;

/**
 * 单据金额，包含单据总金额、毛利或成本等
 * @author evan
 *
 */
public class BillAmount extends BaseModel {

	private static final long serialVersionUID = -3094521169410230975L;

	private Long billId;
	private BigDecimal billAmount = BigDecimal.ZERO;
	private BigDecimal billCostAmount = BigDecimal.ZERO;
	private BigDecimal billSettleAmount = BigDecimal.ZERO;

	/**
	 * 单据Id
	 * @return
	 */
	public Long getBillId() {
		return billId;
	}

	public void setBillId(Long billId) {
		this.billId = billId;
	}

	/**
	 * 总金额
	 * @return
	 */
	public BigDecimal getBillAmount() {
		return billAmount;
	}

	public void setBillAmount(BigDecimal billAmount) {
		this.billAmount = billAmount;
	}
	
	/*
	 * 获取单据金额的大写
	 */
	public String getBillAmountChinese() {
		return ReportUtils.convertMoneyToChinaUpper(billAmount);
	}

	/**
	 * 毛利
	 * @return
	 */
	public BigDecimal getBillProfit() {
		return this.billSettleAmount.subtract(this.billCostAmount);
	}

	/**
	 * 成本金额
	 * @return
	 */
	public BigDecimal getBillCostAmount() {
		return billCostAmount;
	}

	public void setBillCostAmount(BigDecimal billCostAmount) {
		this.billCostAmount = billCostAmount;
	}

	public BigDecimal getBillSettleAmount() {
		return billSettleAmount;
	}

	public void setBillSettleAmount(BigDecimal billSettleAmount) {
		this.billSettleAmount = billSettleAmount;
	}
	
	/*
	 * 获取单据金额的大写
	 */
	public String getBillSettleAmountChinese() {
		return ReportUtils.convertMoneyToChinaUpper(billSettleAmount);
	}

	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("id",this.billId)
		  .append("billAmount",this.billAmount)
		  .append("billSettleAmount",this.billSettleAmount);
		
		return sb.toString();
	}

	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof BillAmount)) {
			return false;
		}
		final BillAmount bill = (BillAmount)o;
		if(billId != null) {
			return billId.equals(bill.getBillId());
		} else {
			return bill.getBillId() == null;
		}
	}

	@Override
	public int hashCode() {
		return (this.billId != null ? this.billId.hashCode() : 0);
	}

}
